<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script type="text/javascript">
    $(function () {
        parent.$.messager.progress('close');
        $('#status').html("");
        $('#sex').html("");
        initSelectAjax("/sysUserController/userGlobalStatus.html", $('#status'), true);
        initSelectAjax("/sysUserController/userSexGlobalStatus.html", $('#sex'), true);
        var newOptions = {
            textField: 'deptName',
            columns: [[{

                title: '编号',
                width: 150,
                checkbox: true
            },{
                field: 'id',
                title: '部门代码',
                width: 100
            }, {
                field: 'deptName',
                title: '部门名称',
                width: 100
            }, {
                field: 'deptMen',
                title: '部门负责人',
                width: 150
            }]]
        }
        initComboDataGrid("/deptController/deptList.html", $("#dept"), newOptions);

        var newOptions2 = {
            singleSelect:false,
            checkOnSelect: false,
            textField: 'roleName',
            columns: [[{
                title: '编号',
                field: 'id',
                width: 150,
                checkbox: true
            }, {
                field: 'roleName',
                title: '角色名称',
                width: 150
            }, {
                field: 'roleInfo',
                title: '角色说明',
                width: 150
            }]]
        }
        initComboDataGrid("/roleController/roleManage.html", $("#roles"), newOptions2);

//        $('#dept').combogrid('grid').datagrid('getSelected').id;

        $('#addFunction').click(function () {
            parent.$.messager.progress({
                title: '提示',
                text: '数据处理中，请稍后....'
            });
            var isValid = $('#form').form('validate');
            if (isValid) {
                parent.$.messager.progress('close');
                var postData = $('#form').serializeJson();
                $.ajax({
                    url: "${pageContext.request.contextPath}/sysUserController/addUser.html",
                    type: "post",
                    dataType: "json",
                    data: postData,
                    success: function (result) {
                        parent.$.messager.progress('close');
                        if (result && isSuccess(result.result)) {
                            parent.$.modalDialog.openner_treeGrid.datagrid('getPager').pagination('select');
                            parent.$.modalDialog.handler.dialog('close');
                            return false;
                        }else{
                            parent.$.messager.alert('提示', result.result + " " + result.message, 'info');
                            return false;
                        }
                        return false;
                    },
                    error: function (result) {
//			internalError();
                        templateInternalError(result.responseText);
                        parent.$.messager.progress('close');
                        return false;
                    }
                });
            } else {
                parent.$.messager.progress('close');
                return isValid;
            }
        });
    });
</script>
<div class="easyui-layout" data-options="fit:true,border:false">
    <div data-options="region:'center',border:false" title="" style="overflow: hidden;">
        <div id="formDiv">
            <form id="form" method="post">
                <div class="fLeft" id="formLeft">
                    <div class="">
                        <label>* 工号:</label>
                        <input class="easyui-validatebox" type="text" name="userNo" data-options="required:true" validType="uniqueUserNo"/>
                    </div>
                    <div>
                        <label>* 账户:</label>
                        <input class="easyui-validatebox" type="text" name="userName" data-options="required:true" validType="uniqueUserName"/>
                    </div>
                    <div>
                        <label>* 密码:</label>
                        <input class="easyui-validatebox" type="text" name="userPassword"
                               data-options="required:true" />
                    </div>
                    <div>
                        <label>* 真实姓名:</label>
                        <input class="easyui-validatebox" type="text" name="trueName" data-options="required:true"/>
                    </div>
                    <div>
                        <label>* 部门:</label>
                        <select id="dept" name="deptNo" style="width:150px" data-options="required:true">
                        </select>
                    </div>
                    <div>
                        <label>* 角色:</label>
                        <select id="roles" name="roleIdsArray" style="width:150px" data-options="required:true,multiple:true">
                        </select>
                    </div>
                    <div>
                        <label>职位名称:</label>
                        <input class="easyui-validatebox" type="text" name="position"/>
                    </div>
                    <div>
                        <label>进入公司日期:</label>
                        <input class="easyui-datebox easyui-validatebox" type="text" name="startDate"/>
                    </div>
                    <div>
                        <label>出生地:</label>
                        <input class="easyui-validatebox" type="text" name="birthPlace"/>
                    </div>
                    <div>
                        <label>性别:</label>
                        <select id="sex" name="sex" data-options="required:true">
                        </select>

                    </div>
                    <div>
                        <label>婚姻状态:</label>
                        <select id="marriage" name="marriage" data-options="required:true">
                            <option value="0">未婚</option>
                            <option value="1">已婚</option>
                        </select>
                    </div>
                    <div>
                        <label>家庭电话:</label>
                        <input class="easyui-validatebox" type="text" name="homePhone"/>
                    </div>

                </div>
                <div class="fLeft" id="formRight">


                    <%--<div>--%>
                        <%--<label>*名称:</label>--%>
                        <%--<input class="easyui-validatebox" type="text" name="name" data-options="required:true"/>--%>
                    <%--</div>--%>
                    <div>
                        <label>* 确认密码:</label>
                        <input class="easyui-validatebox" type="text" name="name" data-options="required:true"/>
                    </div>
                    <div>
                        <label>学历:</label>
                        <input class="easyui-validatebox" type="text" name="education"/>
                    </div>
                    <div>
                        <label>合同到期日:</label>
                        <input class="easyui-datebox easyui-validatebox" type="text" name="overDate"/>
                    </div>
                    <div>
                        <label>籍贯:</label>
                        <input class="easyui-validatebox" type="text" name="nativePlace"/>
                    </div>
                    <div>
                        <label>出生日期:</label>
                        <input class="easyui-datebox easyui-validatebox" type="text" name="birthday" />
                    </div>
                    <div>
                        <label>有效状态:</label>
                        <select id="status" name="status" data-options="required:true">
                        </select>
                    </div>
                    <div>
                        <label>民族:</label>
                        <input class="easyui-validatebox" type="text" name="national" />
                    </div>
                    <div>
                        <label>邮件:</label>
                        <input class="easyui-validatebox" type="text" name="email"  validType="email"/>
                    </div>
                    <div>
                        <label>身份证:</label>
                        <input class="easyui-validatebox" type="text" name="idCard" />
                    </div>
                    <div>
                        <label>联系地址:</label>
                        <input class="easyui-validatebox" type="text" name="address"/>
                    </div>
                        <div>
                            <label>手机:</label>
                            <input class="easyui-validatebox" type="text" name="mobile" validType="length[11,11]"/>
                        </div>
                        <div>
                            <label>备注:</label>
                            <input class="easyui-validatebox" type="text" name="note"/>
                        </div>
                </div>
                <div class="clear"></div>
            </form>
        </div>
    </div>
</div>